package ArryProTest;
//数组遍历
public class Test02 {
   
    public static void main(String[] args) {
        Man m = new Man(10,"许涛涛");
        Man[] mans ={
                m,
                new Man(10,"许涛涛"),
                new Man(20,"杨丹雪"),
                new Man(30,"杨一雪"),
                new Man(40,"杨二雪"),
                new Man(50,"杨三雪")
        };
        mans[0] = m;
        for(int i = 0 ; i<mans.length;i++){
            Man man = mans[i];
            System.out.println(man);
        }
        //增强for循环(一般用于读取元素的值)
        for (Man man : mans) {
            System.out.println(man);
        }
    }
}
class Man{
    private int id;
    private String name;

    public Man(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "id:"+id+",name:"+this.name;
    }

    public Man(){}

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
